@extends('admin.layout')

@section('title', '回复评论')

@section('body')
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div>
                    <textarea name="reply_content" style="width:100%;height:421px">{{ $reply_content }}</textarea>
                </div>
            </div>
            <div style="text-align:center">
                <button class="layui-btn" style="width:150px;margin-top:25px" id="submit-btn">提交保存</button>
            </div>
        </div>
    </div>
    </div>
    <script src="/static/ckeditor/ckeditor.js"></script>
    <script>
        layui.use(['layer', 'form'], function () {
            var $ = layui.$;
            var layer = layui.layer;

            CKEDITOR.replace('reply_content', {height: 320});

            $('#submit-btn').click(function () {
                $.post('/admin/comment/reply', {
                    id: {{ $id }},
                    reply_content: CKEDITOR.instances['reply_content'].getData()
                }, function (res) {
                    if (res.code === 0) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                    } else {
                        layer.msg(res.msg, {icon: 5});
                    }
                }, 'json');
            });
        });
    </script>
@endsection
